package com.xiaoluo.web.form;

import java.util.HashMap;
import java.util.Map;

/**
 * Project : XL-CD
 * Package : com.xiaoluo.web.form
 * Created by Willian.
 * Date  : 2016/1/25 22:51.
 */
public class K8BaseForm {

    private String selector;

    private String labels;

    public String getSelector() {
        return selector;
    }

    public void setSelector(String selector) {
        this.selector = selector;
    }

    public String getLabels() {
        return labels;
    }

    public void setLabels(String labels) {
        this.labels = labels;
    }

    public Map<String,String> getSelectorMap(){
        Map<String,String> result = new HashMap<String, String>();

        if(selector != null && !"".equals(selector)){
            selector.replaceAll("\\{","");
            selector.replaceAll("}","");
            String[] items = selector.split(",");
            if(items !=null && items.length >0){
                for(int i=0;i<items.length;i++){
                    String[] kv =  items[i].split("=");
                    if(kv != null && kv.length >0){
                        result.put(kv[0],kv[1]);
                    }
                }
            }
        }
        return result;
    }

    public Map<String,String> getLabelsMap(){
        Map<String,String> result = new HashMap<String, String>();

        if(labels != null && !"".equals(labels)){
            labels.replaceAll("\\{","");
            labels.replaceAll("}","");
            String[] items = labels.split(",");
            if(items !=null && items.length >0){
                for(int i=0;i<items.length;i++){
                    String[] kv =  items[i].split("=");
                    if(kv != null && kv.length >0){
                        result.put(kv[0],kv[1]);
                    }
                }
            }
        }
        return result;
    }
}
